<template>
  <div class="row justify-content-center">
    <div class="col-8">
      <form name="editForm" role="form" novalidate v-on:submit.prevent="save()">
        <h2 id="roomAdminApp.roomUser.home.createOrEditLabel" data-cy="RoomUserCreateUpdateHeading">Create or edit a RoomUser</h2>
        <div>
          <div class="form-group" v-if="roomUser.id">
            <label for="id">ID</label>
            <input type="text" class="form-control" id="id" name="id" v-model="roomUser.id" readonly />
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-user-nickName">Nick Name</label>
            <input
              type="text"
              class="form-control"
              name="nickName"
              id="room-user-nickName"
              data-cy="nickName"
              :class="{ valid: !$v.roomUser.nickName.$invalid, invalid: $v.roomUser.nickName.$invalid }"
              v-model="$v.roomUser.nickName.$model"
            />
            <div v-if="$v.roomUser.nickName.$anyDirty && $v.roomUser.nickName.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomUser.nickName.maxLength">
                This field cannot be longer than 50 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-user-account">Account</label>
            <input
              type="text"
              class="form-control"
              name="account"
              id="room-user-account"
              data-cy="account"
              :class="{ valid: !$v.roomUser.account.$invalid, invalid: $v.roomUser.account.$invalid }"
              v-model="$v.roomUser.account.$model"
              required
            />
            <div v-if="$v.roomUser.account.$anyDirty && $v.roomUser.account.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomUser.account.required"> This field is required. </small>
              <small class="form-text text-danger" v-if="!$v.roomUser.account.maxLength">
                This field cannot be longer than 30 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-user-password">Password</label>
            <input
              type="text"
              class="form-control"
              name="password"
              id="room-user-password"
              data-cy="password"
              :class="{ valid: !$v.roomUser.password.$invalid, invalid: $v.roomUser.password.$invalid }"
              v-model="$v.roomUser.password.$model"
              required
            />
            <div v-if="$v.roomUser.password.$anyDirty && $v.roomUser.password.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomUser.password.required"> This field is required. </small>
              <small class="form-text text-danger" v-if="!$v.roomUser.password.maxLength">
                This field cannot be longer than 60 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-user-mobile">Mobile</label>
            <input
              type="text"
              class="form-control"
              name="mobile"
              id="room-user-mobile"
              data-cy="mobile"
              :class="{ valid: !$v.roomUser.mobile.$invalid, invalid: $v.roomUser.mobile.$invalid }"
              v-model="$v.roomUser.mobile.$model"
            />
            <div v-if="$v.roomUser.mobile.$anyDirty && $v.roomUser.mobile.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomUser.mobile.maxLength">
                This field cannot be longer than 11 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-user-avatar">Avatar</label>
            <input
              type="text"
              class="form-control"
              name="avatar"
              id="room-user-avatar"
              data-cy="avatar"
              :class="{ valid: !$v.roomUser.avatar.$invalid, invalid: $v.roomUser.avatar.$invalid }"
              v-model="$v.roomUser.avatar.$model"
            />
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-user-slogan">Slogan</label>
            <input
              type="text"
              class="form-control"
              name="slogan"
              id="room-user-slogan"
              data-cy="slogan"
              :class="{ valid: !$v.roomUser.slogan.$invalid, invalid: $v.roomUser.slogan.$invalid }"
              v-model="$v.roomUser.slogan.$model"
            />
          </div>
        </div>
        <div>
          <button type="button" id="cancel-save" data-cy="entityCreateCancelButton" class="btn btn-secondary" v-on:click="previousState()">
            <font-awesome-icon icon="ban"></font-awesome-icon>&nbsp;<span>Cancel</span>
          </button>
          <button
            type="submit"
            id="save-entity"
            data-cy="entityCreateSaveButton"
            :disabled="$v.roomUser.$invalid || isSaving"
            class="btn btn-primary"
          >
            <font-awesome-icon icon="save"></font-awesome-icon>&nbsp;<span>Save</span>
          </button>
        </div>
      </form>
    </div>
  </div>
</template>
<script lang="ts" src="./room-user-update.component.ts"></script>
